package org.jeecg.controller;

import org.jeecg.domain.dto.PriceDto;
import org.jeecg.domain.dto.ServeDto;
import org.jeecg.domain.po.Serve;
import org.jeecg.service.ServeItemService;
import org.jeecg.service.ServeService;
import org.jeecg.service.ServeTypeService;
import org.jeecg.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/serve")
public class ServeController {
    @Autowired
    private ServeService serveService;;
    @Autowired
    private ServeTypeService serveTypeService;
    @Autowired
    private ServeItemService serveItemService;
    /*
    *fzy
    *根据区域id查询服务列表(分页)
    */
//    @CrossOrigin
    @PostMapping("/getServeListByRegionId")
    public ResponseResult getServeListByRegionId(@RequestBody ServeDto dto){
        return serveService.getServeListByRegionId(dto);
    }
    /*
    *fzy
    *根据id删除（逻辑删除）
    */
//    @CrossOrigin
    @GetMapping("/deleteById")
    public ResponseResult deleteById(@RequestParam("id") Long id){
        return serveService.deleteById(id);
    }
    /*
    *fzy
    * 根据服务id设置热门/取消热门
    */
//    @CrossOrigin
    @GetMapping("/setHot")
    public ResponseResult setHotById(@RequestParam("id") Long id){
        return serveService.setHotById(id);
    }
    /*
     *fzy
     * 根据服务id设置上架/下架
     */
//    @CrossOrigin
    @GetMapping("/setSaleStatus")
    public ResponseResult setSaleStatus(@RequestParam("id") Long id){
        return serveService.setSaleStatus(id);
    }
//    添加服务
//    @CrossOrigin
    @PostMapping("/saveServe")
    public ResponseResult saveServe(@RequestBody Serve serve){
        return serveService.saveServe(serve);
    }
//    @CrossOrigin
//    修改区间价格
    @PostMapping("/updatePrice")
    public ResponseResult updatePrice(@RequestBody PriceDto dto){
        return serveService.updatePrice(dto);
    }
//   查看所有的服务类型
    @GetMapping("/typeList")
    public ResponseResult typeList(){
        return serveTypeService.listTypeData();
    }
//    根据服务类型的id查询所有的服务项
    @GetMapping("/serveItemListByTypeId")
    public ResponseResult serveItemListByTypeId(@RequestParam("serveTypeId") String serveTypeId){
        return serveItemService.serveItemListByTypeId(serveTypeId);
    }
}
